package com.espeaker.sdk.api;

import com.espeaker.sdk.Constants;
import com.espeaker.sdk.ESpeakerParameters;
import com.espeaker.sdk.utils.Base64Util;

import android.os.Handler;

public class UserApi extends MiaoApi {
	public void getUserCoin(final String user_id, final Handler handler)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", user_id,true);
					String mRes = request(MiaoApi.GetBaseURL(), USER_GET_COINS, params,2);
					if (handler != null) {
						handler.obtainMessage(Constants.USER_GET_COINS, mRes).sendToTarget();
					}
				} catch (Exception er) {
				}
			}
		}.start();
	}
	public void clearUnRead(final String user_id, final Handler handler)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", user_id,true);
					String mRes = request(MiaoApi.GetBaseURL(), USER_CLEAR_UNREAD, params,2);
					if (handler != null) {
						handler.obtainMessage(Constants.USER_CLEAR_UNREAD, mRes).sendToTarget();
					}
				} catch (Exception er) {
				}
			}
		}.start();
	}
	public void qianDao(final String user_id, final Handler handler)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", user_id,true);
					String mRes = request(MiaoApi.GetBaseURL(), USER_QIANDAO, params,1);
					if (handler != null) {
						handler.obtainMessage(Constants.USER_QIANDAO, mRes).sendToTarget();
					}
				} catch (Exception er) {
				}
			}
		}.start();
	}
	public void hasQianDao(final String user_id, final Handler handler)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", user_id,true);
					String mRes = request(MiaoApi.GetBaseURL(), USER_HASQIANDAO, params,1);
					if (handler != null) {
						handler.obtainMessage(Constants.USER_HASQIANDAO, mRes).sendToTarget();
					}
				} catch (Exception er) {
				}
			}
		}.start();
	}
	public void fankui(final String user_id,final String phone_number,final String content,final Handler handler)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", user_id,true);
					params.add("phone_number", phone_number,true);
					params.add("content", content,true);
					String mRes = request(MiaoApi.GetBaseURL(), USER_FANKUI, params,1);
					if (handler != null) {
						handler.obtainMessage(Constants.USER_FANKUI, mRes).sendToTarget();
					}
				} catch (Exception er) {
				}
			}
		}.start();
	}
}
